package com.example.hm_dtfkz.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.hm_dtfkz.R;
import com.example.hm_dtfkz.entity.BillTypeEntity;
import com.example.hm_dtfkz.entity.BillTypeEntity2;
import com.example.hm_dtfkz.util.ActivityClickUtil;


/**
 * FileName: HomeRunAdapter
 * Author: admin
 * Date: 2021/11/5 14:07
 * Description:
 */
public class BillRunAdapter2 extends BaseQuickAdapter<BillTypeEntity2, BaseViewHolder> {

    private OnItemClickLister clickLister;
    private OnGuideLister guideLister;
    private int rightIndex = -1;

    public BillRunAdapter2() {
        super(R.layout.item_bill_run2);
    }

    @Override
    protected int getDefItemViewType(int position) {
        return position;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, BillTypeEntity2 data) {
        Context context = getContext();
        final int pos = getItemPosition(data);

        ImageView imageview = baseViewHolder.getView(R.id.imageview);

        Glide.with(imageview)
                .load(data.getThumb())
                .placeholder(R.drawable.ic_invite_panel_2)
                .error(R.drawable.ic_invite_panel_2)
                .into(imageview);


        imageview.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                DQLog.e("answer option: " + tvAnswer.getText().toString());
//                DQLog.e("tvAnswer clicked");
                if (ActivityClickUtil.getInstance().isFastClick()) {
                    //防止用户快速点击
                    return;
                }
//                DQLog.e("tvAnswer onItemClick");
                if (clickLister != null) {
                    clickLister.onItemClick(pos, imageview);
                }
            }
        });


    }

    public void setOnItemClickLister(OnItemClickLister lister) {
        this.clickLister = lister;
    }

    public void setGuideLister(OnGuideLister lister) {
        this.guideLister = lister;
    }

    public void setRightIndex(int index) {
        this.rightIndex = index;
    }

    public interface OnItemClickLister {
        void onItemClick(int position, ImageView tvAnswer);
    }

    public interface OnGuideLister {
        void onGuideView(int position, ImageView tvAnswer);
    }
}
